public class MinNumberInRotateArray {
    // 旋转数组的最小数字
    // https://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3FquestionJobId%3D10%26subTabName%3Donline_coding_page&dayCountBigMember=365%E5%A4%A9
    public int minNumberInRotateArray (int[] nums) {
        // write code here
        int left = 0, right = nums.length-1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            // 如果nums[mid] > nums[right]说明mid一定落在做排序数组中
            if (nums[mid] > nums[right]) {
                left = mid + 1;
            } else if (nums[mid] < nums[right]) {
                // nums[mid] < nums[right]说明mid落在排序数组中
                right = mid;
            } else {
                // nums[mid] == nums[right]无法判断落在左旋转数组还是右旋转数组，所以
                // 这里只能缩小区间
                right--;
            }
        }
        return nums[left];
    }
}
